<template>
  <a-card style="width: 100%;">
    <a-form :form="form" class="form">
      <a-form-item label="导师硕士招生年龄线">
        <a-date-picker v-decorator="['masterAgeLine',
          {
            rules: [{ required: true, message: '请选择导师硕士招生年龄线' }],
          }]" style="width: 100%" />
      </a-form-item>
      <a-form-item label="导师博士招生年龄线">
        <a-date-picker v-decorator="['doctorAgeLine',
          {
            rules: [{ required: true, message: '请选择导师博士招生年龄线' }],
          }]" style="width: 100%" />
      </a-form-item>
      <a-row style="text-align: center">
        <a-button type="primary" @click="save" :loading="loading">保存</a-button>
      </a-row>
    </a-form>
  </a-card>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data () {
    return {
      form: this.$form.createForm(this),
      loading: false
    }
  },
  computed: {
    ...mapState({
      systemInfo: state => state.app.systemInfo
    })
  },
  created () {
    this.$store.dispatch('app/sysInfo', true).then(res => {
      this.$nextTick(() => {
        this.form.setFieldsValue({masterAgeLine: res.tutorMasterAdmissionAgeLine, doctorAgeLine: res.tutorDoctoralAdmissionAgeLine})
      })
    })
  },
  methods: {
    save () {
      this.form.validateFields((err, values) => {
        if (err) {
          return
        }
        this.loading = true
        this.$DateToString(values)
        this.$api.teacher.modifyTeacherAgeLine(values).then(res => {
          this.$message.success(res.msg)
        }).finally(() => {
          this.loading = false
        })
      })
    }
  }
}
</script>

<style>

</style>
